/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelImpresora.java
 *
 * Created on 26/08/2011, 19:08:45
 */
package tsb.UI.Paneles;

import tsb.dominio.interfaces.*;
import java.util.ArrayList;
import tsb.UI.Ventanas.VentanaDeError;
import tsb.dominio.enumeraciones.AsignacionIP;


/**
 *
 * @author Fede
 */
public class PanelImpresora extends javax.swing.JPanel {

   private boolean pestaña1=false; // para saber si la pestaña ya tiene un panel
    

    private ArrayList<InterfaceDeConeccion> listaInterfaces;
    
    public PanelImpresora() {
        initComponents();
        this.btnQuitarInterfazPestaña1.setVisible(false);
        
        listaInterfaces = new ArrayList<InterfaceDeConeccion>();
    }

     private void insertarPanel(javax.swing.JPanel p, String panel)
    {
        this.panelPestaña1.add(p);
        pestañasInterfaces.setTitleAt(0, panel);
        this.pestaña1=true;
        this.btnQuitarInterfazPestaña1.setVisible(true);
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PestañasConfiguraciones = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        txtNombreAMostrar = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        cmbencendido = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtGateway = new javax.swing.JTextField();
        txtServidorDNS = new javax.swing.JTextField();
        rbtDCHP = new javax.swing.JRadioButton();
        rbtStatic = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        cmbIntefaces = new javax.swing.JComboBox();
        btnAgregar = new javax.swing.JButton();
        pestañasInterfaces = new javax.swing.JTabbedPane();
        panelPestaña1 = new javax.swing.JPanel();
        btnQuitarInterfazPestaña1 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        PestañasConfiguraciones.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        txtNombreAMostrar.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel2.setText("Nombre a Mostrar:");

        cmbencendido.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "     SI", "     NO" }));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel1.setText("Encendido:");

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Gateway/DNS"));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel4.setText("Forma de Asignacion IP:");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel3.setText("Gateway:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel5.setText("Servidor DNS:");

        txtGateway.setEnabled(false);

        txtServidorDNS.setEnabled(false);

        rbtDCHP.setBackground(new java.awt.Color(255, 255, 255));
        rbtDCHP.setFont(new java.awt.Font("Tahoma", 0, 14));
        rbtDCHP.setSelected(true);
        rbtDCHP.setText("DHCP");
        rbtDCHP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                rbtDCHPMouseClicked(evt);
            }
        });

        rbtStatic.setBackground(new java.awt.Color(255, 255, 255));
        rbtStatic.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        rbtStatic.setText("Static");
        rbtStatic.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                rbtStaticMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rbtStatic)
                            .addComponent(rbtDCHP)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtServidorDNS)
                            .addComponent(txtGateway, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)))))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(rbtDCHP))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rbtStatic)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtGateway, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtServidorDNS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtNombreAMostrar, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE))
                            .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(100, 100, 100))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(119, 119, 119)
                                .addComponent(cmbencendido, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(222, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtNombreAMostrar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(cmbencendido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(33, 33, 33)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(186, Short.MAX_VALUE))
        );

        PestañasConfiguraciones.addTab("Configuraciones", jPanel1);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        cmbIntefaces.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ethernet", "Fast Ethernet RJ45", "Fast Ethernet Fibra Optica", "Gigabit RJ45", "Gigabit Fibra Optica", "Modem", "Serial", "Wireless" }));

        btnAgregar.setText("Agregar");
        btnAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarActionPerformed(evt);
            }
        });

        panelPestaña1.setBackground(new java.awt.Color(255, 255, 255));

        btnQuitarInterfazPestaña1.setText("Quitar Interfaz");
        btnQuitarInterfazPestaña1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarInterfazPestaña1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelPestaña1Layout = new javax.swing.GroupLayout(panelPestaña1);
        panelPestaña1.setLayout(panelPestaña1Layout);
        panelPestaña1Layout.setHorizontalGroup(
            panelPestaña1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPestaña1Layout.createSequentialGroup()
                .addContainerGap(293, Short.MAX_VALUE)
                .addComponent(btnQuitarInterfazPestaña1))
        );
        panelPestaña1Layout.setVerticalGroup(
            panelPestaña1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPestaña1Layout.createSequentialGroup()
                .addContainerGap(331, Short.MAX_VALUE)
                .addComponent(btnQuitarInterfazPestaña1))
        );

        pestañasInterfaces.addTab("Interfaz 1", panelPestaña1);

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel6.setText("Interfaces de Conección");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pestañasInterfaces, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(cmbIntefaces, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnAgregar))
                    .addComponent(jLabel6))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmbIntefaces, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAgregar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pestañasInterfaces, javax.swing.GroupLayout.PREFERRED_SIZE, 382, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        PestañasConfiguraciones.addTab("Interfaces", jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 425, Short.MAX_VALUE)
            .addComponent(PestañasConfiguraciones, javax.swing.GroupLayout.PREFERRED_SIZE, 425, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 484, Short.MAX_VALUE)
            .addComponent(PestañasConfiguraciones, javax.swing.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void rbtDCHPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rbtDCHPMouseClicked
        this.txtGateway.setEnabled(false);
        this.txtServidorDNS.setEnabled(false);
        
        this.setAsignacionIPPanel(this.panelPestaña1,AsignacionIP.DCHP);
        
}//GEN-LAST:event_rbtDCHPMouseClicked

    private void rbtStaticMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rbtStaticMouseClicked
        this.txtGateway.setEnabled(true);
        this.txtServidorDNS.setEnabled(true);
        
        
        this.setAsignacionIPPanel(this.panelPestaña1,AsignacionIP.Static);
       
    }//GEN-LAST:event_rbtStaticMouseClicked

    private void btnAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarActionPerformed
        
        if(!this.pestaña1) {
            switch(this.cmbIntefaces.getSelectedIndex()) {
                case 0:
                    PanelEthernet pe = new PanelEthernet();
                    pe.setAsignacion(this.getAsignacionIP());
                    pe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                    this.insertarPanel(pe,"Ethernet");
                    break;
                case 1:
                    PanelFastEthernetRJ45 pfe = new PanelFastEthernetRJ45();
                    pfe.setAsignacion(this.getAsignacionIP());
                    pfe.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                    this.insertarPanel(pfe,"Fast Ethernet RJ45");
                    break;
                case 2:
                    PanelFastEthernetFibra pfef = new PanelFastEthernetFibra();
                    pfef.setAsignacion(this.getAsignacionIP());
                    pfef.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                    this.insertarPanel(pfef,"Fast Ethernet Fibra Óptica");
                    break;
                case 3:
                    PanelGigabitRJ45 pg = new PanelGigabitRJ45();
                    pg.setAsignacion(this.getAsignacionIP());
                    pg.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                    this.insertarPanel(pg,"Gigabit RJ45");
                    break;
                case 4:
                    PanelGigabitFibra pgf = new PanelGigabitFibra();
                    pgf.setAsignacion(this.getAsignacionIP());
                    pgf.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                    this.insertarPanel(pgf,"Gigabit Fibra Óptica");
                    break;
                case 5:
                    PanelModemPC pm = new PanelModemPC();
                    pm.setAsginarIP(this.getAsignacionIP());
                    pm.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                    this.insertarPanel(pm,"Modem");
                    break;
                case 6:
                    PanelSerial ps = new PanelSerial();
                    ps.setAsignacion(this.getAsignacionIP());
                    ps.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                    this.insertarPanel(ps,"Serial");
                    break;
                case 7:
                    PanelWireless pw = new PanelWireless();
                    pw.setAsignacionIP(this.getAsignacionIP());
                    pw.setBounds(0, 0, 396, 320);//(X,Y, ancho,alto,)[396, 320]
                    this.insertarPanel(pw,"Wireless");
                    break;
            }
        } else {
            VentanaDeError.mostrarDialog("No se puede agregar interfaz", "             La PC solo acepta 1 Interfaces de coneccion.\nPara agregar una nueva debe quitar alguna de las interfaces actuales", 0);
        }
}//GEN-LAST:event_btnAgregarActionPerformed

    private void btnQuitarInterfazPestaña1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarInterfazPestaña1ActionPerformed
        
        this.panelPestaña1.remove(this.panelPestaña1.getComponent(1));
        this.pestaña1=false;
        pestañasInterfaces.setTitleAt(0, "Interfaz 1");
        this.btnQuitarInterfazPestaña1.setVisible(false);
}//GEN-LAST:event_btnQuitarInterfazPestaña1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane PestañasConfiguraciones;
    private javax.swing.JButton btnAgregar;
    private javax.swing.JButton btnQuitarInterfazPestaña1;
    private javax.swing.JComboBox cmbIntefaces;
    private javax.swing.JComboBox cmbencendido;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel panelPestaña1;
    private javax.swing.JTabbedPane pestañasInterfaces;
    private javax.swing.JRadioButton rbtDCHP;
    private javax.swing.JRadioButton rbtStatic;
    private javax.swing.JTextField txtGateway;
    private javax.swing.JTextField txtNombreAMostrar;
    private javax.swing.JTextField txtServidorDNS;
    // End of variables declaration//GEN-END:variables

      private void setAsignacionIPPanel(javax.swing.JPanel p, AsignacionIP ip)
    {
         if(p.getComponent(1) instanceof tsb.UI.Paneles.PanelEthernet)
        {
           PanelEthernet pe = (PanelEthernet)p.getComponent(1);
           pe.setAsignacion(ip);
           return;
        }

        if(p.getComponent(1) instanceof PanelFastEthernetRJ45)
        {
            PanelFastEthernetRJ45 pe = (PanelFastEthernetRJ45)p.getComponent(1);
             pe.setAsignacion(ip);
             return;
        }
        if(p.getComponent(1) instanceof PanelFastEthernetFibra)
        {
            PanelFastEthernetFibra pe = (PanelFastEthernetFibra)p.getComponent(1);
             pe.setAsignacion(ip);
           return;
        }
        if(p.getComponent(1) instanceof PanelGigabitRJ45)
        {
            PanelGigabitRJ45 pe = (PanelGigabitRJ45)p.getComponent(1);
             pe.setAsignacion(ip);
           return;
        }
        if(p.getComponent(1) instanceof PanelGigabitFibra)
        {
            PanelGigabitFibra pe = (PanelGigabitFibra)p.getComponent(1);
            pe.setAsignacion(ip);
            return;
        }
        if(p.getComponent(1) instanceof PanelSerial)
        {
            PanelSerial pe = (PanelSerial)p.getComponent(1);
             pe.setAsignacion(ip);
           return;
        }
        if(p.getComponent(1) instanceof PanelModemPC)
        {
            PanelModemPC pe = (PanelModemPC)p.getComponent(1);
             pe.setAsginarIP(ip);
           return;
        }
         if(p.getComponent(1) instanceof PanelWireless)
        {
            PanelWireless pe = (PanelWireless)p.getComponent(1);
             pe.setAsignacionIP(ip);
           return;
        }
        
    }
      
       public void setNombreAMostrar(String nombre)
    {
        this.txtNombreAMostrar.setText(nombre);
    }
    
    public String getNombreAMostrar()
    {
        return this.txtNombreAMostrar.getText();
    }
    
    public void setEncendido(boolean encendido)
    {
        if(encendido)
        {
            this.cmbencendido.setSelectedIndex(0);
        }
        else
        {
            this.cmbencendido.setSelectedIndex(1);
        }
    }
    
    public boolean getEncendido()
    {
        if(this.cmbencendido.getSelectedIndex()==0)
            return true;
        else
            return false;
    }
    
    public void setAsignacionIP(AsignacionIP asignacion)
    {
        if(asignacion== AsignacionIP.DCHP)
        {
            this.rbtDCHP.setSelected(true);
        }
        else
        {
            this.rbtStatic.setSelected(true);
        }
    }
    
    public AsignacionIP getAsignacionIP()
    {
        if(this.rbtDCHP.isSelected())
            return AsignacionIP.DCHP;
        else
            return AsignacionIP.Static; 
    }
    
    public void setGateway(IP gw )
    {
        if(gw!=null)
        {
            this.txtGateway.setText(gw.toString());
        }
    }
    
    public IP getGateway()
    {
        IP ip = new IP(this.txtGateway.getText());
        return ip;
    }
    
    public void setServidorDNS(IP dns)
    {
        if(dns!=null)
        {
            this.txtServidorDNS.setText(dns.toString());
        }
    }
    
    public IP getServdorDNS()
    {
        IP dns = new IP(this.txtServidorDNS.getText());
        return dns;
    }
    
    public ArrayList<InterfaceDeConeccion> getInterfaces()
    {
        return this.listaInterfaces;
    }
    
    public InterfaceDeConeccion getInterfaz1()
    {
        if(this.panelPestaña1.getComponent(1) instanceof tsb.UI.Paneles.PanelEthernet)
        {
           PanelEthernet pe = (PanelEthernet)this.panelPestaña1.getComponent(1);
            System.out.println(pe.getEthernet().toString());
            return pe.getEthernet();
        }
        else
        {
            if(this.panelPestaña1.getComponent(1) instanceof PanelFastEthernetRJ45)
            {
                PanelFastEthernetRJ45 pe = (PanelFastEthernetRJ45)this.panelPestaña1.getComponent(1);
                System.out.println(pe.getRJ45FastEthernet().toString());
                return pe.getRJ45FastEthernet();
            }
            else
            {
                if(this.panelPestaña1.getComponent(1) instanceof PanelFastEthernetFibra)
                {
                    PanelFastEthernetFibra pe = (PanelFastEthernetFibra)this.panelPestaña1.getComponent(1);
                    System.out.println(pe.getFibraOpticaFastEthernet().toString());
                    return pe.getFibraOpticaFastEthernet();
                }
                else
                {
                    if(this.panelPestaña1.getComponent(1) instanceof PanelGigabitRJ45)
                    {
                        PanelGigabitRJ45 pe = (PanelGigabitRJ45)this.panelPestaña1.getComponent(1);
                        System.out.println(pe.getFibraOpticaGigabit().toString());
                        return pe.getFibraOpticaGigabit();
                    }
                    else
                    {
                        if(this.panelPestaña1.getComponent(1) instanceof PanelGigabitFibra)
                        {
                            PanelGigabitFibra pe = (PanelGigabitFibra)this.panelPestaña1.getComponent(1);
                            System.out.println(pe.getFibraOpticaGigabit().toString());
                            return pe.getFibraOpticaGigabit();
                        }
                        else
                        {
                            if(this.panelPestaña1.getComponent(1) instanceof PanelModemPC)
                            {
                                PanelModemPC pe = (PanelModemPC)this.panelPestaña1.getComponent(1);
                                System.out.println(pe.getInterfazModem().toString());
                                return pe.getInterfazModem();
                            }
                            else
                            {
                                if(this.panelPestaña1.getComponent(1) instanceof PanelSerial)
                                {
                                    PanelSerial pe = (PanelSerial)this.panelPestaña1.getComponent(1);
                                    System.out.println(pe.getSerial().toString());
                                    return pe.getSerial();
                                }
                                else
                                {
                                     if(this.panelPestaña1.getComponent(1) instanceof PanelWireless)
                                    {
                                        PanelWireless pe = (PanelWireless)this.panelPestaña1.getComponent(1);
                                        System.out.println(pe.getWireless().toString());
                                        return pe.getWireless();
                                    }
                                }
                                
                            }
                            
                        }
                        
                    }
                    
                }
                
            }
        }
        return null;
    }
}
